#include <cstdlib>
#include "impl.h"

int SKEL_WIDTH = 800;
int SKEL_HEIGHT = 600;

int main(int argc, char * argv[])
{
	if (!cmdline(argc, argv))
		exit(1);

	SDL_Init(SDL_INIT_VIDEO);
	atexit(cleanup);
	atexit(SDL_Quit);

	SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 );
	SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 );
	SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 );
	SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
	SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, SKEL_VSYNC);

	if (SDL_SetVideoMode(SKEL_WIDTH, SKEL_HEIGHT, SKEL_BITDEPTH, 
			     SDL_OPENGL|SKEL_FULLSCREEN) == NULL) {
		exit(1);
	}

	init();

	bool cont = true;
	while(cont) {
		draw();

		SDL_Event ev;
		while(SDL_PollEvent(&ev))
			cont &= event(&ev);
	}

	return 0;
}

